# -*- coding: utf-8 -*-
from flask import Flask,render_template,jsonify,request
import json,requests
import BiliBiliApi,cloud
from flask_cors import *

app = Flask(__name__)
app.config['JSON_AS_ASCII'] = False
CORS(app, supports_credentials=True)

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/wordcloud/<av>', methods=['POST'])
def getWordCloud(av):
    file,img,cover = BiliBiliApi.getData(av)
    if img == '':
        return jsonify({'code':0})
        
    path = cloud.run(av,file,img)
    data = {
        'code':1,
        'cover':cover,
        'url':path
    }
    return jsonify(data)
